﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SouthApps.MobileHealth.SDK.DAL.Model;

namespace SouthApps.MobileHealth.SDK.DAL.DataAccess
{
    public class PermissionDao : DataAccessObject
    {
        public List<Permission> GetUserPermissions(int userId)
        {
            try
            {
                using (var entities = this.EntityContext)
                {
                    var query = from e in entities.userpermission.Include("Permission").Include("User")
                                where (e.userId == userId)
                                select e.permission;

                    return query.ToList();
                }
            }
            catch (Exception ex)
            {
                throw this.HandleException(ex);
            }
        }
    }
}
